import Vue from 'vue'
import Cookies from 'js-cookie'
import Element from 'element-ui'
import { EnableUaaClient } from '@/router/router-guard'
// >>>>>>>>>>>>>>>>>> person_start >>>>>>>>>>>>>>>>>>>>>>>>>
import store from './store'
import router from './router'
import './permission'
import {FontAwesomeIcon} from '@fortawesome/vue-fontawesome'

import * as filters from './filters' ;

// >>>>>>>>>>>>>>>>>> alinesno-ui_start TODO 待整合成一个包 >>>>>>>>>>>>>>>>>>>>>>>>>
import 'alinesno-ui/src/assets/styles/element-variables.scss'
import 'alinesno-ui/src/assets/icons' // icon
import 'alinesno-ui/src/assets/styles/index.scss' // global css
import 'alinesno-ui/src/assets/styles/ruoyi.scss' // ruoyi css
import SvgIcon from 'alinesno-ui/packages/SvgIcon' // svg component
import App from 'alinesno-ui/src/App'
import permission from 'alinesno-ui/src/directive/permission'
import {
  addDateRange,
  download,
  handleTree,
  parseDatetime,
  parseTime,
  resetForm,
  selectDictLabel,
  selectDictLabels
} from 'alinesno-ui/src/utils/ruoyi'
import Pagination from 'alinesno-ui/packages/Pagination'
import RightToolbar from 'alinesno-ui/packages/RightToolbar' // 自定义表格工具扩展
import {use} from "echarts/core";
import {CanvasRenderer} from "echarts/renderers";
import {LineChart, PieChart} from "echarts/charts";
import {LegendComponent, TitleComponent, TooltipComponent} from "echarts/components";
import {searchParam} from "alinesno-ui/packages/Search/searchform";
// >>>>>>>>>>>>>>>>>> person_end >>>>>>>>>>>>>>>>>>>>>>>>>

// 全局方法挂载
Vue.prototype.parseTime = parseTime
Vue.prototype.parseDatetime = parseDatetime
Vue.prototype.resetForm = resetForm
Vue.prototype.addDateRange = addDateRange
Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.selectDictLabels = selectDictLabels
Vue.prototype.download = download
Vue.prototype.handleTree = handleTree
Vue.prototype.searchParam = searchParam
Vue.prototype.msgSuccess = function (msg) {
  this.$message({showClose: true, message: msg, type: 'success'})
}

Vue.prototype.msgError = function (msg) {
  this.$message({showClose: true, message: msg, type: 'error'})
}

Vue.prototype.msgInfo = function (msg) {
  this.$message.info(msg)
}

// 全局组件挂载
Vue.component('svg-icon', SvgIcon)
Vue.component('Pagination', Pagination)
Vue.component('RightToolbar', RightToolbar)
Vue.component('font-awesome-icon', FontAwesomeIcon)

Vue.use(permission)

// 全局修改默认配置，点击空白处不能关闭弹窗
Element.Dialog.props.closeOnClickModal.default = false

Vue.use(Element, {
  size: Cookies.get('size') || 'medium' // set element-ui default size
})
Vue.config.productionTip = false
Vue.use(EnableUaaClient, {routerInstance: router})

Object.keys(filters).forEach(key => {
  Vue.filter(key , filters[key]) ;
})

// >>>>>>>>>>>>>>>>>> alinesno-ui_end >>>>>>>>>>>>>>>>>>>>>>>>>

use([
  CanvasRenderer,
  PieChart,
  LineChart,
  TitleComponent,
  TooltipComponent,
  LegendComponent
]);

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})

